package com.yanqu.road.server.cmd.assistant;

import com.yanqu.road.pb.assistant.AssistantProto;
import com.yanqu.road.pb.estatewar.EstateWarProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.palace.PalaceModule;
import com.yanqu.road.server.manger.assistant.AssistantMgr;
import com.yanqu.road.server.manger.assistant.handler.EscortCrossActionHandler;
import com.yanqu.road.server.manger.assistant.handler.UnionCrossActionHandler;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameProtocol;
import com.yanqu.road.utils.BitUtil;

@Cmd(code = GameProtocol.S_ASSISTANT_PALACE_WORSHIP_ACTION_FROM_CROSS, desc = "皇城膜拜返回")
public class AssistantPalaceWorshipActionFromCross extends AbstractCommand {

    private AssistantProto.AssistantCrossActionRespMsg.Builder builder;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        builder = AssistantProto.AssistantCrossActionRespMsg.parseFrom(packet.getBytes()).toBuilder();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        // 处理皇城响应
        AssistantProto.AssistantActionReqMsg.Builder assistantReq = builder.getAssistantActionReqMsg().toBuilder();
        AssistantProto.AssistantActionRespMsg.Builder assistantResp = builder.getAssistantActionRespMsg().toBuilder();
        assistantResp.setPalaceWorshipRespMsg(player.getModule(PalaceModule.class).worshipResponse(assistantResp.getPalaceWorshipRespMsg()));
        builder.setAssistantActionRespMsg(assistantResp);
        // 押镖操作
        new EscortCrossActionHandler().handle(player, assistantReq, assistantResp);
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
